Developer Documentation

QuickTime 4 API Documentation

Inside Macintosh: QuickTime

Previous | Overview | Contents | Next |

Working With the StdPix Function

To allow applications to have access to compressed image data as it is displayed, a new graphics function has been added to the grafProcs field of the color graphics port structure (defined by the CGrafPort data type). See Inside Macintosh: Imaging for more information about the color graphics port structure.

The StdPix function extends the current grafProcs field to support compressed data, mattes, and matrices. The new function supports pixel maps and allows you to intercept image data in compressed form before it is decompressed and displayed. For example, you can use the StdPix function to collect compressed image data that is to be processed and printed. In addition, your application can call the StdPix function directly.

The replaced grafProcs field is referred to in the original QuickDraw documentation as the newProc1 field. The standard handler is called StdPix , and you obtain its address by calling QuickDraw's SetStdCProcs routine. Alternatively, your application can call the StdPix function directly, using the interface described here. Your application can intercept the low-level grafProcs drawing routines just as it would any of the other routines, except that you must call SetStdCProcs to gain access to the standard grafProcs handler.

Note
QuickDraw's CopyDeepMask function uses the StdPix function if QuickTime is present.

See Inside Macintosh: Imaging for more information about the QuickDraw low-level drawing routines, the SetStdCProcs routine, the QDProcs structure, and the CopyDeepMask routine.

To work with the control information associated with a compressed image, you can use the SetCompressedPixMapInfo and GetCompressedPixMapInfo functions (described on SetCompressedPixMapInfo and GetCompressedPixMapInfo , respectively).

StdPix

The Image Compression Manager lets you invoke QuickDraw's StdPix function as follows:

pascal void StdPix (PixMapPtr src, const Rect *srcRect,
                                         MatrixRecordPtr matrix, short mode,
                                         RgnHandle mask, PixMapPtr matte,
                                         const Rect *matteRect, short flags);
src
Contains a pointer to a pixel map containing the image to draw. Use the GetCompressedPixMapInfo function (described on GetCompressedPixMapInfo ) to retrieve information about this pixel map.

srcRect
Points to a rectangle defining the portion of the image to display. This rectangle must lie within the boundary rectangle of the compressed image or within the source image. If this parameter is set to nil , the entire image is displayed.

matrix
Contains a pointer to a matrix structure that specifies the mapping of the source rectangle to the destination. It is a fixed-point, 3-by-3 matrix. This roughly corresponds to the dstRect parameter to QuickDraw's StdBits routine. See the chapter "Movie Toolbox" in this book for more information about matrix operations.

mode
Specifies the transfer mode for the operation. The Image Compression Manager supports the same transfer modes supported by QuickDraw's CopyBits routine.

Note that this parameter also controls the accuracy of any decompression operation that may be required to display the image. If bit 7 (0x80) of the mode parameter is set to 1, the StdPix function sets the decompression accuracy to codecNormalQuality . If this bit is set to 0, the function sets the accuracy to codecHighQuality .

mask
Contains a handle to a clipping region in the destination coordinate system. If specified, the compressor applies this mask to the destination image. If there is no mask, this parameter is set to nil .

matte
Points to a pixel map that contains a blend matte. The blend matte causes the decompressed image to be blended into the destination pixel map. The matte can be defined at any supported pixel depth--the matte depth need not correspond to the source or destination depths. However, the matte must be in the coordinate system of the source image. If there is no matte, this parameter is set to nil .

The matte may be compressed. Use the GetCompressedPixMapInfo function (described on GetCompressedPixMapInfo ) to determine if the matte pixel map contains compressed data.

matteRect
Contains a pointer to a rectangle defining a portion of the blend matte to apply. This parameter is set to nil if there is no matte or if the entire matte is to be used.

flags
Contains control flags. The following flags are available:

callOldBits
If this flag is set, then the StdPix function calls QuickDraw's bitsProc routine with the decompressed image data. A pointer to this routine is located in the bitsProc field of the CQDProcs record. If the bitsProc routine is not customized, then it is not called unless the callStdBits flag is also set. See the description of the CQDProcs record in Inside Macintosh: Imaging for more on the bitsProc routine.

callStdBits
If this flag is set, the callOldBits flag is set, and the CQDProcs record's bitsProc field is set to the StdBits routine, then the StdBits routine is called with the decompressed image data.

noDefaultOpcodes
If this flag is set and a picture is open for writing, the default picture opcodes (for displaying a warning when QuickTime is not installed) are not added to the output picture. This can be useful when storing multiple StdPix opcodes in a single picture.

SetCompressedPixMapInfo

The SetCompressedPixMapInfo function allows your application to store information about a compressed image for the StdPix function (described in the previous section).

pascal OSErr SetCompressedPixMapInfo (PixMapPtr pix,
                                          ImageDescriptionHandle desc,
                                         Ptr data, long bufferSize,
                                         ICMDataProcRecordPtr dataProc,
                                         ICMProgressProcRecordPtr progressProc);
pix
Points to a structure that holds encoded compressed image data.

desc
Contains a handle to the image description structure that defines the compressed image.

data
Points to the buffer for the compressed image data. If the entire compressed image cannot be stored at this location, you may assign a data-loading function (see the discussion of the dataProc parameter to this function). This pointer must contain a 32-bit clean address.

bufferSize
Specifies the size of the buffer to be used by the data-loading function specified by the dataProc parameter. If there is no data-loading function defined for this operation, set this parameter to 0.

dataProc
Points to a data-loading function structure. If there is not enough memory to store the compressed image, the decompressor calls a function you provide that loads more compressed data (see "Data-Loading Functions," for more information about data-loading functions). If you do not want to assign a data-loading function, set this parameter to nil .

progressProc
Points to a progress function structure. During the decompression operation, the decompressor may occasionally call a function you provide in order to report its progress (see "Progress Functions," for more information about progress functions). If you do not want to assign a progress function, set this parameter to nil . If you pass a value of -1, you obtain a standard progress function.

DESCRIPTION

The SetCompressedPixMapInfo function stores information in a structure that is identical to a PixMap structure, but the structure represents the compressed data, not the actual pixel map. You can use the SetCompressedPixMapInfo if you are working with the StdPix function (described on StdPix ).

RESULT CODES

paramErr

-50

Invalid parameter specified

SEE ALSO

You can retrieve information about a compressed pixel map by calling the GetCompressedPixMapInfo function, which is described in the next section.

GetCompressedPixMapInfo

The GetCompressedPixMapInfo function allows your application to retrieve information about a compressed image.

pascal OSErr GetCompressedPixMapInfo (PixMapPtr pix,
                                         ImageDescriptionHandle *desc,
                                         Ptr *data, long *bufferSize,
                                         ICMDataProcRecord *dataProc,
                                         ICMProgressProcRecord *progressProc);
pix
Points to a structure that holds encoded compressed image data.

desc
Contains a pointer to a field that is to receive a handle to the image description structure that defines the compressed image. If you are not interested in this information, you may specify nil in this parameter.

data
Contains a pointer to a field that is to receive a pointer to the compressed image data. If the entire compressed image cannot be stored at this location, you can define a data-loading function for this operation (see the discussion of the dataProc parameter to this function). If you are not interested in this information, you may specify nil in this parameter.

bufferSize
Contains a pointer to a field that is to receive the size of the buffer to be used by the data-loading function specified by the dataProc parameter. If there is no data-loading function defined for this operation, this parameter is ignored. If you are not interested in this information, you may specify nil in this parameter.

dataProc
Contains a pointer to a data-loading function structure. If there is not enough memory to store the compressed image, the decompressor calls a function you provide that loads more compressed data (see "Data-Loading Functions," for more information about data-loading functions). If there is no data-loading function for this image, the function sets the dataProc field in the function structure to nil . If you are not interested in this information, you may specify nil in this parameter.

progressProc
Contains a pointer to a progress function structure. During a decompression operation, the decompressor may occasionally call a function you provide in order to report its progress (see "Progress Functions," for more information about progress functions). If there is no progress function for this image, the function sets the progressProc field in the function structure to nil . If you pass a value of -1, you obtain a standard progress function. If you are not interested in this information, you may specify nil in this parameter.

DESCRIPTION

The data in the compressed image has been encoded in a PixMap structure with the SetCompressPixMapInfo function. This is the kind of pixel map that may be passed into the StdPix function. If you pass a normal, non-encoded pixel map, GetCompressedPixMapInfo returns a paramErr result code. You use the GetCompressedPixMapInfo function if you are intercepting calls to the StdPix function.

SPECIAL CONSIDERATIONS

The pixel map structure filled in by the GetCompressedPixMapInfo function should not be used by any other Macintosh functions. It is only to be used by the StdPix function.

RESULT CODES

paramErr

-50

Invalid parameter specified

SEE ALSO

You can set information about a compressed pixel map by calling the SetCompressedPixMapInfo function, which is described in the previous section.


© 1999 Apple Computer, Inc.

Previous | Overview | Contents | Next